// pages/addCar/carDetail/index.js catDetail
import { catDetail } from "../../../api/addCar/index"

Page({

  /**
   * 页面的初始数据
   */
  data: {
    mainActiveIndex: 0,
    activeId: null,
    items:[
      {
        text:'1.4T(30TFSI)',
        children:[
          {
            text:"2017款",
          },
          {
            text:"2018款",
          },
          {
            text:"2019款",
          },
          {
            text:"2020款",
          },
          {
            text:"2021款",
          }
        ]
      },
      {
        text:'1.4T(35TFSI)',
        children:[
          {
            text:"2017款",
          },
          {
            text:"2018款",
          },
          {
            text:"2019款",
          },
          {
            text:"2020款",
          },
          {
            text:"2021款",
          }
        ]
      },
      {
        text:'1.4T(40TFSI)',
        children:[
          {
            text:"2017款",
          },
          {
            text:"2018款",
          },
          {
            text:"2019款",
          },
          {
            text:"2020款",
          },
          {
            text:"2021款",
          }
        ]
      }
    ],
    name:'',
    logo:'',
    carname:'',
    carlogo:'',
  },
  onClickNav({ detail = {} }) {
    this.setData({
      mainActiveIndex: detail.index || 0,
    });
  },
  handleClick(event){
    wx.navigateTo({
      url: '/pages/addCar/addFrom/index?id=' + event.currentTarget.dataset.id + '&name=' + this.data.carname+ event.currentTarget.dataset.dis + event.currentTarget.dataset.name + '&logo=' + this.data.logo,
    })
  },
  onClickItem({ detail = {} }) {
    const activeId = this.data.activeId === detail.id ? null : detail.id;

    this.setData({ activeId });
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {
    console.log(options)
    this.data.carlogo = options.logo
    this.data.carname = options.name
    catDetail({
      parentid:options.id
    }).then(res=>{
      console.log(res)
      this.setData({
        list:res.data.data.list,
        name:res.data.data.fullname,
        logo:res.data.data.logo
      })
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})